package com.itheima.mapper;

import com.itheima.pojo.Emp;
import com.itheima.pojo.PageSelect;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

/*
 * 员工管理Mapper
 * */
@Mapper
public interface EmpMapper {

//    @Select("SELECT * from emp where name like concat('%',#{name},'%') and gender=#{gender} and entrydate between #{begin} and #{end}")
    List<Emp> list(String name, Short gender, LocalDate begin, LocalDate end);

//    @Delete("DELETE from emp where id in (#{ids})")
    void delete(List<Integer> ids);


    @Insert("INSERT INTO emp(username, password, name, gender, image, job, entrydate, dept_id, create_time, update_time)" +
            "values(#{username},#{password},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime}) ")
    void insert(Emp emp);


    void update(Emp emp);

    /*
    * 分页查询获取列表数据的方法
    * */
//    @Select("SELECT * from emp limit #{start},#{pageSize}")
//    List<Emp> page(Integer start,Integer pageSize);

    /*
    * 总记录数
    * */
//    @Select("SELECT count(*) from emp")
//    public long total();

    /*
    * 根据id查询数据
    * */
    @Select("SELECT * from emp where id =#{id}")
    public Emp getByid(Integer id);

    @Select("SELECT * from emp where username=#{username} and password = #{password}")
    Emp login(Emp emp);
}
